  // ------------------------------------------
  // UserAgent Class - for browser detection
  //  just use for example -   useragent.isie
  // ------------------------------------------
  function UserAgent() {
    this.versionstring = navigator.appVersion;
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
		
    try {
  	  if (navigator.appMinorVersion != undefined)
	  this.appMinor = navigator.appMinorVersion.toLowerCase();  else this.appMinor = "";
	} catch(e) {
	  this.appMinor = "";
	}

    this.appName = navigator.appName;
  	this.agent = navigator.userAgent;
    this.agt = this.agent.toLowerCase();
	
    this.iswindows = this.agt.indexOf('windows') != -1;
	this.ismac = this.agt.indexOf('mac') != -1;

    this.isfirefox = this.agt.indexOf('firefox') != -1;
    this.isseamonkey = this.agt.indexOf('seamonkey') != -1;
	this.isopera = this.agt.indexOf('opera') != -1;	
	this.isie = (this.agt.indexOf('msie') != -1) && (!this.isopera); 
	this.ismozilla = this.agt.indexOf('gecko') != -1;
	this.iswebtv = this.agt.indexOf('webtv') != -1;
	this.isaol = this.agt.indexOf('aol') != -1;	
	this.isnetscape = (this.agt.indexOf('mozilla') != -1) && (!this.isie) && (!this.iswebtv);
	this.issafari = this.agt.indexOf('safari') != -1;
		

	this.version = 6;
	
	// browser specific version parsing
	if (this.isie) {
	  var tmp = this.agt.indexOf('msie') + 5;
	  this.version = parseFloat(this.agt.substring(tmp));
	} else
	if (this.isopera) {
	  var tmp = this.agt.indexOf('opera') + 6;
	  this.version = parseFloat(this.agt.substring(tmp));
	} else
	if (this.issafari) {
	  var tmp = this.agt.indexOf('safari/') + 7;
  	  var tmpV = parseFloat(this.agt.substring(tmp));	
	  this.version = 1.0;
	  if (tmpV >= 100) this.version = 1.1;
	  if (tmpV >= 125) this.version = 1.2;
	  if (tmpV >= 312) this.version = 1.3;	  
	  if (tmpV >= 412) this.version = 2.0;	  	  
	}	else
	if (this.ismozilla) {
	  var tmp = this.agt.indexOf('netscape6/') + 10;
	  this.version = parseFloat(this.agt.substring(tmp));
	} else
	if (this.isnetscape) {
	  var tmp = this.agt.indexOf('mozilla/') + 8;
	  this.version = parseFloat(this.agt.substring(tmp));
	}
	
	this.isie3 = (this.isie) && (this.version < 4);

    this.language = 'en-US';	
	// try getting language
	if (this.version >= 4) {
	  if (this.isie) this.language = navigator.userLanguage;
	  if (this.isnetscape) this.language = navigator.language;
	}

    this.supportsActiveX = (this.iswindows) && (this.isie);
    this.supportsPlugins = (this.iswindows) && ((this.isnetscape) || (this.ismozilla));
    this.supportsWebPrinting = (this.supportsActiveX) || (this.supportsPlugins);
	this.isXP = (this.agt.indexOf('nt 5.1') != -1) && (this.iswindows);
	this.isXPSP2 = (this.isXP) && (this.appMinor.indexOf('sp2') != -1);
	this.isVista = (this.agt.indexOf('NT 6.0') != -1) && (this.iswindows);
	this.isWindowsMediaCenter = (this.iswindows) && (this.agt.indexOf('Media Center PC') != -1);
	this.supportsFilters = (this.iswindows) && (this.isie);
	this.isIntelMac = this.agt.indexOf('intel mac') != -1;
	this.isIE7 = (this.isie) && (this.version >= 7);
	this.axYellowBar = (this.supportsActiveX) && ((this.isXPSP2) || (this.isVista) || (this.isIE7));

    return this;
  }
  
  UserAgent.prototype.toString = function() {
    return this.agent;
  }

  UserAgent.prototype.canDisableStatusBar = function() {
    return false;
  }
  
  UserAgent.prototype.supportsYUI = function() {
	  var retval = true;
	  if ((this.issafari) && (this.version < 2)) retval = false;
    return retval;
  }
	
	
  // create an instance that we can use globally
  var useragent = new UserAgent();


  // ------------------------------------------
  // Dialog Class - for popup windows
  // ------------------------------------------
  var windowhandle = null;

  function Dialog(width,height,url,name) {
    this.width = width;
	this.height = height;
	this.url = url;
	this.top = 0;
	this.left = 0;
	this.windowname = name;
	this.scrollbars = false;
	this.resizable = false;
	this.toolbar = false;
	this.handle = null;
	this.statusbar = false;
	this.showPopupStopperMessage = false;
	this.windowDescription = "";
	
	if (useragent.iswebtv) {
	  window.open(this.url,this.windowname,"scrollbars=yes");
	}
  }

  Dialog.prototype.show = function() {
     if ((windowhandle == null) || (windowhandle.closed) ){
  	  this.calculateLocation();
	  windowhandle = window.open(this.url, this.windowname, this.features());
	  this.handle = windowhandle;
	} else {
	  windowhandle.focus();
	  windowhandle.location = this.url;
	}
	
	var success = windowhandle != null;
	
	if ((!success) && (this.showPopupStopperMessage)) {
	  var msg = "Your popup stopper blocked ";
	  if (this.windowDescription != "") {
	    msg += "the " + this.windowDescription + " window from displaying.";
	  } else {
	    msg += "a dialog from from showing properly.";
	  }
	  msg += " Please configure your popup stopper to allow popups on FotoTime for this to work properly.";
	  alert(msg);
	}
	
	return success;
  }

  Dialog.prototype.features = function() {
    var Features = "scrollbars=";

    if (this.scrollbars) Features += "yes"; else Features += "no";
	
    Features += ",resizable=";
    if (this.resizable) Features += "yes"; else Features += "no";	
	
    Features += ",toolbar=";
    if (this.toolbar) Features += "yes"; else Features += "no";		
	
    Features += ",status=";
    if (this.statusbar) Features += "yes"; else Features += "no";
	
    Features += ",width=" + this.width + ",height=" + this.height;
    Features += ",top=" + this.top + ",left=" + this.left;

    //alert(Features);
    return Features;
  }

  Dialog.prototype.calculateLocation = function() {
    if ((!useragent.isie3) && (!useragent.isaol)) {
	  this.width = (this.width > screen.width ? (screen.availWidth-30): this.width);
	  this.height = (this.height > screen.height ? (screen.availHeight-30): this.height);	  
	  this.top = ((screen.availHeight - 25) - this.height) / 2;
	  this.left = ((screen.availWidth - 25) - this.width) / 2;
	}
  }

  // ------------------------------------------
  // Dialog routines used in more than one place
  // ------------------------------------------
  //function subDlg() { var sdlg = new Dialog(525,305,"/pages/ftregistertrial","TrialWin"); sdlg.show(); }
  function subDlg() { window.location = "/pages/ftSubInfo" }
  function subDiscountDlg() { var sdlg = new Dialog(525,305,"/pages/ftsubprices","SubPriceWin"); sdlg.show(); }  
  function emailDlg() { var edlg = new Dialog(525,345,"/pages/ftregisteremail","EmailWin"); edlg.show(); }
  function notLoggedIn(GotoURL) { var ndlg = new Dialog(525,400,"/ftweb/bin/ft.dll/shopnologin?dest=" + GotoURL,"LoginWin"); ndlg.show(); }


  // ------------------------------------------
  // Other global utility functions
  // ------------------------------------------
  function SetStatusBar(str)
  {
    str = unescape(str);
    window.status = str;
  }

  function changeImages(imgname, imgurl)
  {
    //var el = document.all[imgname];
    imgname.src = imgurl;
  }
  
  function findComponent(name) {
    var cb = null;
    if (document.all)
    {
      cb = document.all[name];
    }
    else
    {
      var n = 0;
      while (n < document.printselection.elements.length) 
      {	
        if (document.printselection.elements[n].name == name) 
	    cb = document.printselection.elements[n];		
	    n = n + 1;
      }
    }
    return(cb);	  
  }


  function tellServerMyTime() {
    var img = new Image();
    var d = new Date();
    var fn = "/ftweb/bin/ft.dll/reporttime?month=" + (d.getMonth() + 1);
    fn += "&day=" + d.getDate();
    fn += "&year=" + d.getFullYear();
    fn += "&hour=" + d.getHours();
    fn += "&minutes=" + d.getMinutes();
	  fn += "&lang=" + useragent.language;
	  //fn += "&lang=" + 'hu';
    img.src = fn;
		var dt = GetCookie("dTime");
		if (dt == "1") alert(fn);
  }

  function createCookie(name,value,days) {
	  if (days) {
		  var date = new Date();
  		date.setTime(date.getTime()+(days*24*60*60*1000));
	  	var expires = "; expires="+date.toGMTString();
  	}
  	else var expires = "";
  	document.cookie = name+"="+value+expires+"; path=/";
  }

  function debugTime(do_debug) {
		if (do_debug) {
			createCookie("dTime", "1", 365);
			alert("Time debugging on");
		} else {
			createCookie("dTime", "0", 365);
			alert("Time debugging off");			
		}
  }


  String.prototype.lTrim = function() {	
	  var tmp = this;
	  while (tmp.substring(0,1) == ' ') tmp = tmp.substring(1,tmp.length);
	  while (tmp.charCodeAt(0) == 160) tmp = tmp.substring(1,tmp.length);		
		return(tmp);
  }

  String.prototype.rTrim = function() {
	  var tmp = this;
    while (tmp.substring(tmp.length-1, tmp.length) == ' ') tmp = tmp.substring(0,tmp.length-1);
    while (tmp.charCodeAt(tmp.length-1) == 160) tmp = tmp.substring(0,tmp.length-1);		
    return tmp;		
	}

	String.prototype.trim = function() {
		var tmp = this.lTrim();
		tmp = tmp.rTrim();
		return tmp;
	}


  function Trim(AStr) {
    AStr = escape(AStr.replace(/^\s+/,'').replace(/\s+$/,''));
    return AStr.replace(/^%A0+/, '').replace(/%A0+$/,'');
  }

  function TrimNoEscape(AStr) {
    AStr = escape(AStr.replace(/^\s+/,'').replace(/\s+$/,''));
    AStr = AStr.replace(/^%A0+/, '').replace(/%A0+$/,'');
    AStr = unescape(AStr);
    return (AStr);
  }

  function currentDateString() {
    var retval = "";
    var d = new Date();
    var x = new Array("Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday");
    var y = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    retval += x[d.getDay()]+ ", ";
    retval += y[d.getMonth()];
    retval += " " + d.getDate() + ", ";
    retval += d.getFullYear();
    return(retval);
  }

function CheckForCookies() {
  var enabled = false;
  if ((useragent.isie) && (!useragent.isie3)) {
    enabled = (navigator.cookieEnabled);
  } else {
    document.cookie = 'CookiesSupported';
	enabled = (document.cookie);
  }
  
  if (!enabled) alert("Cookies must be enabled to use FotoTime.");
  return enabled;
}  

function GetCookie(sName) {
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++) {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) return unescape(aCrumb[1]); // found a match - return it
  }
 
  return null; // a cookie with the requested name does not exist
}

  function getQueryParm(urlstr, findstr) {
   var searchString = urlstr;
   var retval = "";
   qpos = searchString.indexOf("?");
   searchString=searchString.slice(qpos + 1,searchString.length); //remove ?
   var pairs=searchString.split("&");
   for(i=0; i<pairs.length; i++){
     var myString=pairs[i];	//get the current pair
	 var epos = myString.indexOf("=");
     var varname  = myString.slice(0,epos); 
     var varvalue = myString.slice(epos+1,myString.length);
	 if (varname == findstr) retval = varvalue
   }
   return retval;
  }


  function StartSlideshowFromThumbs(UserId, AlbumId, GroupId, UsePopup, JSSlideshow) {
		// calculate the url to use
		
		var ScreenHeight = window.screen.height;		
	  var URL = '/ftweb/bin/ft.dll/detail';
		if (!UsePopup) URL += 'fs';
		URL += '?userid=' + UserId + '&ndx=0&AlbumId=' +AlbumId + '&GroupId=' + GroupId  + '&screenheight=' + ScreenHeight;
		if (JSSlideshow) URL += '&autostart=1'; else URL += '&slideshow=1';
		
		if (UsePopup) {			
			var WinHeight = 550;
			var WinWidth  = 800;
			var cururl = window.location.href.toUpperCase();
			var isReal = cururl.indexOf("REAL") > 0;
	
			if (ScreenHeight > 600) WinHeight = 620;
			if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
			if (isReal) WinWidth += 50;
	
			// status bar is included in height - have to add on if disabling status bar doesnt work
			if (!useragent.canDisableStatusBar()) WinHeight += 25;
		
			try {
				if (showBanners) WinHeight += 75;
				
			} catch (e) {
				// do nothing
			}  
	
			var slideDlg = new Dialog(WinWidth,WinHeight, URL, "DetailWin");
	
			if (ScreenHeight < 600) slideDlg.scrollbars = true;
			var cururl = window.location.href.toUpperCase();
			if (cururl.indexOf("/PICTURES") <= 0) {
				window.location = '/ftweb/bin/ft.dll/pictures?UsePopup=true';	
			}
		
			var success = false;
			try {
				success = slideDlg.show();
			} catch (e) {
				success = false;
			}
		
			if (!success) {
				var fs = confirm("Your popup stopper blocked the popup slideshow.  Would you like to use the non-popup version?");
				if (fs) Detail(UserId, Ndx, AlbumId, GroupId);
			}
			
		} else {
    	window.location = URL;			
		}
	}

  
  function DetailWin(UserId, Ndx, AlbumId, GroupId, SearchStr) {
    var WinHeight = 550;
    var WinWidth  = 800;
    var cururl = window.location.href.toUpperCase();
    var isReal = cururl.indexOf("REAL") > 0;
    var ScreenHeight = window.screen.height;

    if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
    if (isReal) WinWidth += 50;

    // status bar is included in height - have to add on if disabling status bar doesnt work
    if (!useragent.canDisableStatusBar()) WinHeight += 25;
	
    try {
      if (showBanners) WinHeight += 75;
      
    } catch (e) {
      // do nothing
    }  

    var URL = '/ftweb/bin/ft.dll/detail?userid=' + UserId + '&ndx=' + Ndx + '&slideshow=0&AlbumId=' +AlbumId + '&GroupId=' + GroupId  + '&screenheight=' + ScreenHeight;

    var slideDlg = new Dialog(WinWidth,WinHeight, URL, "DetailWin");

    if (ScreenHeight < 600) slideDlg.scrollbars = true;
    var cururl = window.location.href.toUpperCase();
    if (cururl.indexOf("/PICTURES") <= 0) {
      window.location = '/ftweb/bin/ft.dll/pictures?UsePopup=true';	
    }
	
    var success = false;
    try {
      success = slideDlg.show();
    } catch (e) {
      success = false;
    }
	
    if (!success) {
      var fs = confirm("Your popup stopper blocked the popup slideshow.  Would you like to use the non-popup version?");
      if (fs) Detail(UserId, Ndx, AlbumId, GroupId);
    }
  }

  function Detail(UserId, Ndx, AlbumId, GroupId) {
	var ScreenHeight = window.screen.height;

    var URL = '/ftweb/bin/ft.dll/detailfs?userid=' + UserId + '&ndx=' + Ndx + '&slideshow=0&AlbumId=' +AlbumId + '&GroupId=' + GroupId  + '&screenheight=' + ScreenHeight;
    window.location = URL;
  }


  function isVideo(filename)
  {
    var retval = false;
    if (filename != "")
	{
	  filename = filename.toLowerCase();
	  if (!retval) retval = filename.indexOf("avi") != -1;
	  if (!retval) retval = filename.indexOf("mov") != -1;
	  if (!retval) retval = filename.indexOf("mpg") != -1;
	  if (!retval) retval = filename.indexOf("mpeg") != -1;
	  if (!retval) retval = filename.indexOf("wmv") != -1;	  	  	  	  
	  if (!retval) retval = filename.indexOf("asf") != -1;	  	  	  	  	  
	  if (!retval) retval = filename.indexOf("flv") != -1;	  	  	  	  	  
	}
	return retval;
  }

  function canShowPreview(filename)
  {
    var retval = false;
    if (filename != "")
	{
	  filename = filename.toLowerCase();
	  if (!retval) retval = filename.indexOf("jpg") != -1;
	  if (!retval) retval = filename.indexOf("jpeg") != -1;
	  if (!retval) retval = filename.indexOf("gif") != -1;
	  if (!retval) retval = filename.indexOf("bmp") != -1;
	}
	return retval;
  }

  function MoveTo(FromList, ToList)
  {
    Idx = FromList.selectedIndex;
    Tot = ToList.options.length;
    if (Idx >= 0)
    {
       MoveText = FromList[Idx].text;
       MoveVal  = FromList[Idx].value;
       Opt = new Option(MoveText, Tot);
       ToList[Tot] = Opt;
       ToList[Tot].value =  MoveVal;
       FromList.options[Idx] = null;
       FromList.selectedIndex = 0;
       ToList.selectedIndex = Tot;
    }    
  }

  
  function LoadValues(List, HiddenFld)
  {
    var TmpStr = "";
    var item = "";
    Tot = List.options.length;
    for (i=0; i <= Tot - 1; i++)
    {
      if (TmpStr != "")
        TmpStr = TmpStr + ',';
      item = List[i].value;
      if (item.indexOf(' ') > 0)
        item = '"' + item + '"';
      TmpStr = TmpStr + item;
    }
    HiddenFld.value = TmpStr;
  }
  
  function toggleDiv(divid) {
    var mdiv = document.getElementById(divid);
	var gbtn = document.getElementById("g" + divid);
	if (mdiv.style.display != "none")  {
	  mdiv.style.display = "none";
 	  document.cookie = divid + "=0";
	  gbtn.src = "/ftweb/images/real/menuplus.gif";
	} else {
	  mdiv.style.display = "block";
 	  document.cookie  = divid + "=1";	  
	  gbtn.src = "/ftweb/images/real/menuminus.gif";	  
	}
  }
  
   function ViewCommentsWin(UserId, Ndx, AlbumId, GroupId, PictureId) {
    WinHeight = 550;
    WinWidth  = 650;

	var cururl = window.location.href.toUpperCase();
    var isReal = cururl.indexOf("REAL") > 0;
	var ScreenHeight = window.screen.height;
	if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
	if (isReal) WinWidth += 50;

    var URL = '/ftweb/bin/ft.dll/picturecomments?userid=' + UserId + '&ndx=' + Ndx + '&slideshow=0&AlbumId=' +AlbumId + '&GroupId=' + GroupId  + '&pictid=' + PictureId;

    var commentsDlg = new Dialog(WinWidth,WinHeight, URL, "CommentsWin");
	commentsDlg.scrollbars = true;
	commentsDlg.windowDescription = "photo comments";
	commentsDlg.showPopupStopperMessage = true;	
    commentsDlg.show();
  }

   function AddCommentWin(UserId, Ndx, AlbumId, GroupId, PictureId) {
    WinHeight = 550;
    WinWidth  = 650;

	var cururl = window.location.href.toUpperCase();
    var isReal = cururl.indexOf("REAL") > 0;
	var ScreenHeight = window.screen.height;
	if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
	if (isReal) WinWidth += 50;

    var URL = '/ftweb/bin/ft.dll/addcomment?userid=' + UserId + '&ndx=' + Ndx + '&slideshow=0&AlbumId=' +AlbumId + '&GroupId=' + GroupId  + '&pictid=' + PictureId;

    var commentsDlg = new Dialog(WinWidth,WinHeight, URL, "CommentsWin");
	commentsDlg.scrollbars = true;
	commentsDlg.windowDescription = "photo comments";
	commentsDlg.showPopupStopperMessage = true;	
    commentsDlg.show();
  }

   function AddCommentWinGallery(UserId, PictureId) {
    WinHeight = 550;
    WinWidth  = 650;

	var cururl = window.location.href.toUpperCase();
    var isReal = cururl.indexOf("REAL") > 0;
	var ScreenHeight = window.screen.height;
	if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
	if (isReal) WinWidth += 50;

    var URL = '/ftweb/bin/ft.dll/addcommentg?userid=' + UserId + '&pictid=' + PictureId;

    var commentsGDlg = new Dialog(WinWidth,WinHeight, URL, "CommentsGWin");
	commentsGDlg.scrollbars = true;
	commentsGDlg.windowDescription = "photo gallery comments";
	commentsGDlg.showPopupStopperMessage = true;	
    commentsGDlg.show();
  }
  
   function ViewCommentsGallery(UserId, PictureId) {
    WinHeight = 550;
    WinWidth  = 650;
	
	var cururl = window.location.href.toUpperCase();
    var isReal = cururl.indexOf("REAL") > 0;
	var ScreenHeight = window.screen.height;
	if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
	if (isReal) WinWidth += 50;

    var url = '/ftweb/bin/ft.dll/picturecommentsg?userid=' + UserId + '&pictid=' + PictureId;
    var commentsDlg = new Dialog(WinWidth,WinHeight, url, "CommentsWin");
	commentsDlg.scrollbars = true;
	commentsDlg.windowDescription = "photo comments";
	commentsDlg.showPopupStopperMessage = true;	
    commentsDlg.show();
  }




   function AddCommentWinGallerySearch(UserId, PictureId) {
    WinHeight = 550;
    WinWidth  = 650;

  	var cururl = window.location.href.toUpperCase();
	  var ScreenHeight = window.screen.height;
	  if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
    var URL = '/ftweb/bin/ft.dll/addcommentgs?userid=' + UserId + '&pictid=' + PictureId;

    var commentsGDlg = new Dialog(WinWidth,WinHeight, URL, "CommentsGWin");
	  commentsGDlg.scrollbars = true;
	  commentsGDlg.windowDescription = "photo gallery comments";
	  commentsGDlg.showPopupStopperMessage = true;	
    commentsGDlg.show();
  }
  
   function ViewCommentsGallerySearch(UserId, PictureId) {
    WinHeight = 550;
    WinWidth  = 650;
	
	  var cururl = window.location.href.toUpperCase();
	  var ScreenHeight = window.screen.height;
	  if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;

    var url = '/ftweb/bin/ft.dll/picturecommentsgs?userid=' + UserId + '&pictid=' + PictureId;
    var commentsDlg = new Dialog(WinWidth,WinHeight, url, "CommentsWin");
	  commentsDlg.scrollbars = true;
	  commentsDlg.windowDescription = "photo comments";
	  commentsDlg.showPopupStopperMessage = true;	
    commentsDlg.show();
  }






   function ViewCommentsURL(url) {
    WinHeight = 550;
    WinWidth  = 650;
	
	var cururl = window.location.href.toUpperCase();
    var isReal = cururl.indexOf("REAL") > 0;
	var ScreenHeight = window.screen.height;
	if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
	if (isReal) WinWidth += 50;

    var commentsDlg = new Dialog(WinWidth,WinHeight, url, "CommentsWin");
	commentsDlg.scrollbars = true;
	commentsDlg.windowDescription = "photo comments";
	commentsDlg.showPopupStopperMessage = true;	
    commentsDlg.show();
  }

   function AddCommentURL(url) {
    WinHeight = 550;
    WinWidth  = 650;

	var cururl = window.location.href.toUpperCase();
    var isReal = cururl.indexOf("REAL") > 0;
	var ScreenHeight = window.screen.height;
	if (ScreenHeight > 600) WinHeight = 620;
    if ((useragent.ismac) && (useragent.isie)) WinHeight = WinHeight + 40;
	if (isReal) WinWidth += 50;
	
    var commentsDlg = new Dialog(WinWidth,WinHeight, url, "CommentsWin");
	commentsDlg.scrollbars = true;
	commentsDlg.windowDescription = "photo comments";
	commentsDlg.showPopupStopperMessage = true;
    commentsDlg.show();
  }

  function editPictKeywords(pictid,fld) {
    var url = "/ftweb/bin/ft.dll/picturekeywords?pictid=" + pictid + "&fld=" + fld;
    var kwDlg = new Dialog(300,400, url, "keywords");
    kwDlg.scrollbars = true;
	kwDlg.resizable = true;
	kwDlg.windowDescription = "keywords";
	kwDlg.showPopupStopperMessage = true;
    kwDlg.show();
  }
	
	


function rebarTable(table) {
	var even = false;
	
	// by definition, tables can have more than one tbody
	// element, so we'll have to get the list of child
	// &lt;tbody&gt;s 
	var tbodies = table.getElementsByTagName("tbody");

	// and iterate through them...
	for (var h = 0; h < tbodies.length; h++) {    
		var trs = tbodies[h].getElementsByTagName("tr");
		for (var i = 0; i < trs.length; i++) {
			trs[i].className = even ? "even" : "odd";
			even =  ! even;
		}
	}
}

function rebarTables() {
	var tables = document.getElementsByTagName("TABLE");
	i = 0;
	while (i < tables.length) {
	  var tb = tables[i];
		if (tb.className == "ftgrid rebar") rebarTable(tb);
		i++;
	}
}

function rebarTableV2(table) {
	var even = false;
	
	// by definition, tables can have more than one tbody
	// element, so we'll have to get the list of child
	// &lt;tbody&gt;s 
	var tbodies = table.getElementsByTagName("tbody");

	// and iterate through them...
	for (var h = 0; h < tbodies.length; h++) {    
		var trs = tbodies[h].getElementsByTagName("tr");
		for (var i = 0; i < trs.length; i++) {
			trs[i].className = even ? "" : "rbar";
			even =  ! even;
		}
	}
}

function rebarTablesV2() {
	var tables = document.getElementsByTagName("TABLE");
	i = 0;
	while (i < tables.length) {
	  var tb = tables[i];
		if (tb.className == "data_table auto_rbar") rebarTableV2(tb);
		i++;
	}
}


function tomail(epart1, epart2)
{
  var url = 'mailto:';
  url += epart1;
  url += epart2;
  url += '@fot';
  url += 'otime.com';
  window.location = url;
}

function windowWidth() {
  var winWidth, d=document;
  if (typeof window.innerWidth!='undefined') {
    winWidth = window.innerWidth;
  } else {
    if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
      winWidth = d.documentElement.clientWidth
    } else {
      if (d.body && typeof d.body.clientWidth!='undefined') {
        winWidth = d.body.clientWidth
      }
    }
  }
  return winWidth;
}

function windowHeight() {
  var winHeight, d=document;
  if (typeof window.innerHeight!='undefined') {
    winHeight = window.innerHeight;
  } else {
    if (d.documentElement && typeof d.documentElement.clientHeight!='undefined' && d.documentElement.clientHeight!=0) {
      winHeight = d.documentElement.clientHeight
    } else {
      if (d.body && typeof d.body.clientHeight!='undefined') {
        winHeight = d.body.clientHeight
      }
    }
  }
  return winHeight;
}


function jsonErrorCondition(msg) {
  ndx = msg.indexOf("Error:");
  if (ndx >=0) {
    alert(msg);
	return(true);
  } else {
    return(false);
  }
}

function disableButton(button) {
  var btnid = null;
  var vBtn = typeof button;
  if (vBtn == "string") {
    btnid = document.getElementById(button);
  } else {
    btnid = button;
  } 

  try {
    btnid.disabled = true;
  } catch(e) {
  }
  
  try {
    btnid.setAttribute("disabled","disabled");
  } catch(e) {
  }

  try {  
    if (useragent.isfirefox) {
      btnid.style.color = "#c0c0c0";
	  btnid.style.opacity = 0.8;
    }
  } catch(e) {
  }
  
}

function disableButtons(idSave,idCancel,saveMessage) {
  var btnSave = null;
  var btnCancel = null;
  var vtSave = typeof idSave;
  if (vtSave == "string") {
    btnSave = document.getElementById(idSave);
  } else {
    btnSave = idSave;
  }
  
  disableButton(btnSave);
  if (saveMessage) btnSave.value = saveMessage;

  if (idCancel) {  
    var vtCancel = typeof idCancel;
    if (vtCancel == "string") {
      btnCancel = document.getElementById(idCancel);
    } else {
      btnCancel = idCancel;
    }
    disableButton(btnCancel);
  }
  
  
}

function hasPicLensInstalled() {
  //return false;
  // IE Windows
  if (useragent.supportsActiveX) {
    try {
      var pl = new ActiveXObject("PicLens.Context");
      var plt = typeof pl;
      if (plt == "object") return(true); else return(false);
      return(true);
    } catch(e) {
      return(false);
    }
  }

  // firefox
  if (typeof PicLensContext != 'undefined') return(true);


  // now have to figure out safari 


  return(false);
}

function wmpVersion() {
  return(11);
}

function hasWMPFixPlugin() {
  var retval = false;
  if (navigator.plugins && navigator.plugins.length) {
    for (var i=0; i < navigator.plugins.length; i++ ) {
      var plugin = navigator.plugins[i];
      if (plugin.name.indexOf("Windows Media Player Firefox Plugin") > -1) {
        retval = true;
      }
    }
  }
  return(retval);
}

function noCurlys(guid) {
  var retval = guid;
  var s = retval.indexOf('{');
  var e = retval.indexOf('}');
  if ((s == 0) && (e == 37)) {
    retval = retval.substring(1,37);
  }
  return(retval);
}

function getE(eId) {
  var a = document.getElementById(eId);
  return a;
}

function setHTML(eId, eHtml) {
  var a = getE(eId);
  if (a) a.innerHTML = eHtml;
}

function stopEvent(ev) {
  stopPropagation(ev);
  preventDefault(ev);
}

function stopPropagation(ev) {
  if (ev.stopPropagation) {
    ev.stopPropagation();
  } else {
    ev.cancelBubble = true;
  }
}

function preventDefault(ev) {
  if (ev.preventDefault) {
    ev.preventDefault();
  } else {
    ev.returnValue = false;
  }
}

